package com.mdxx.xczd.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.mdxx.xczd.bean.MessageEvent;

import org.greenrobot.eventbus.EventBus;

import cn.jpush.android.api.JPushInterface;

/**
 * 推送广播20161014
 */
public class PushReceiver extends BroadcastReceiver {	
	@Override
	public void onReceive(Context context, Intent intent) {
		Bundle bundle = intent.getExtras();
		if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
			processCustomMessage(context, bundle);
		} 
	}	
	
	private void processCustomMessage(Context context, Bundle bundle) {
		String title = bundle.getString(JPushInterface.EXTRA_TITLE);
		String msg = bundle.getString(JPushInterface.EXTRA_MESSAGE);
		String extra = bundle.getString(JPushInterface.EXTRA_EXTRA);
		EventBus.getDefault().post(new MessageEvent(msg, extra, 1));
	}

}
